//
//  TZL_MineController.m
//  MyTabbarDemo
//
//  Created by Yuki on 2021/10/11.
//

#import "TZL_MineController.h"
#import <CYLBadgeProtocol.h>
#import "AppDelegate.h"
#import "TZL_PlusButton.h"
#import <SDWebImage.h>
@interface TZL_MineController ()<CYLBadgeProtocol>

@end

@implementation TZL_MineController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navgationTitle = @"我的";
    self.navView.showBackBtn = NO;
    
    //修改角标
    [self changeBadge];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self changeTabbar];        
    });
}
//修改tabbar
- (void)changeTabbar{
   
    NSLog(@"%@",self.tabBarController);
    NSLog(@"%@",self.tabBarController.tabBar);
    NSLog(@"%@",self.tabBarController.tabBar.subviews);
    
    //修改tabbar的发布按钮
    [self.tabBarController.tabBar.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[TZL_PlusButton class]]) {
            TZL_PlusButton *btn = (TZL_PlusButton *)obj;
            NSString *path = [[NSBundle mainBundle] pathForResource:@"sendgif" ofType:@"gif"];
            NSURL *url = [NSURL fileURLWithPath:path];
            btn.contentMode = UIViewContentModeScaleAspectFit;
            [btn sd_setImageWithURL:url forState:UIControlStateNormal];
        }
    }];
    
}



/// 修改角标
- (void)changeBadge{
    //    修改角标
    [self cyl_setBadgeFont:[UIFont systemFontOfSize:10 weight:UIFontWeightRegular]];
    [self cyl_setBadgeTextColor:UIColor.whiteColor];
    [self cyl_setBadgeBackgroundColor:UIColor.redColor];
    [self cyl_setBadgeCenterOffset:CGPointMake(0, 10)];
    [self cyl_showBadge];
    [self cyl_showBadgeValue:@"" animationType:CYLBadgeAnimationTypeNone];
}



@end
